home *** CD-ROM | disk | FTP | other *** search
- unit MonWndU;
-
- interface
-
- uses
- Forms, Messages, Windows;
-
- type
- THelperForm = class(TForm)
- public
- MonitorWnd: HWnd;
- MonitorProcess,
- MonitorLibProcess: THandle;
- TraceValue: Integer;
- procedure WndProc(var Msg: TMessage); override;
- end;
-
- var
- HelperForm: THelperForm;
-
- implementation
-
- uses
- MonHelpU, MonLibU;
-
- procedure THelperForm.WndProc(var Msg: TMessage);
- begin
- inherited;
- //Monitor tells us its window handle
- if Msg.Msg = wm_MonitorNotify then
- begin
- MonitorWnd := TWMMonitorNotify(Msg).Wnd;
- GetWindowThreadProcessId(MonitorWnd, @MonitorProcess);
- MonitorLibProcess := GetCurrentProcess;
- TraceValue := TWMMonitorNotify(Msg).TraceValue;
- end
- else
- //Monitor tells us to reset client trace flags
- if Msg.Msg = wm_UpdateClients then
- begin
- //Don't bother, if this is the DLL loaded by the monitor
- if HelperForm.MonitorProcess = HelperForm.MonitorLibProcess then
- Exit;
- TraceValue := TWMUpdateClients(Msg).TraceValue;
- UpdateClients(TraceValue);
- end
- end;
-
- initialization
- HelperForm := THelperForm.CreateNew(nil);
- //Tell monitor the handle of this library form window
- //The monitor will send a message back to let us know its window handle
- SendMessage(HWnd_Broadcast, wm_ClientLibNotify, HelperForm.Handle, 0);
- finalization
- HelperForm.Free
- end.
-